package org.oslims.client.uicomponents.editbox;

import org.oslims.client.uicomponents.inputfields.SelectManyBox;
import org.oslims.domain.Department;
import org.oslims.domain.Operator;

public class EditOperatorBox extends EditUserBox {

	final SelectManyBox<Department> departmentSelection = new SelectManyBox<Department>("Departments:");

	private Operator operator;

	public EditOperatorBox() {
		// Call super to generate the default fields for a user
		super();

		// Add the department selection box
		editUserBoxPanel.add(departmentSelection);

		// Add the save and cancel buttons
		editUserBoxPanel.add(buttonLine);
	}

	@Override
	protected void clear() {
		super.clear();

	}

	public SelectManyBox<Department> getDepartmentSelection() {
		return departmentSelection;
	}

	public void showNew() {
		this.clear();
		this.clearAllErrors();
		this.operator = null;
		editUserBox.setText("Create new Lab Responsible");
		editUserBox.center();
	}

	public void showEdit(Operator operator) {
		this.clear();
		this.clearAllErrors();
		this.operator = operator;
		editUserBox.setText("Edit Lab Responsible");
		super.showEdit(operator);

		editUserBox.center();
	}

	public void showError(String fieldName, String message) {

		super.showError(fieldName, message);
	}

	public void clearError(String fieldName) {

		super.clearError(fieldName);
	}

	public void clearAllErrors() {
		super.clearAllErrors();
	}

	public void setOperator(Operator operator) {
		this.operator = operator;
	}

	public Operator getOperator() {
		return operator;
	}
}
